cmake_minimum_required(VERSION 3.22)
project(Sofa.Component.LinearSolver.Preconditioner LANGUAGES CXX)

set(SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR "src/sofa/component/linearsolver/preconditioner")

set(HEADER_FILES
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/config.h.in
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/init.h
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/BlockJacobiPreconditioner.h
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/BlockJacobiPreconditioner.inl
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/JacobiPreconditioner.h
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/JacobiPreconditioner.inl
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/PrecomputedWarpPreconditioner.h
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/PrecomputedWarpPreconditioner.inl
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/SSORPreconditioner.h
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/SSORPreconditioner.inl
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/WarpPreconditioner.h
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/WarpPreconditioner.inl
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/RotationMatrixSystem.h
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/RotationMatrixSystem.inl
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/PrecomputedMatrixSystem.h
)

set(SOURCE_FILES
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/init.cpp
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/BlockJacobiPreconditioner.cpp
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/JacobiPreconditioner.cpp
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/PrecomputedWarpPreconditioner.cpp
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/SSORPreconditioner.cpp
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/WarpPreconditioner.cpp
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/RotationMatrixSystem.cpp
    ${SOFACOMPONENTLINEARSOLVERPRECONDITIONER_SOURCE_DIR}/PrecomputedMatrixSystem.cpp
)

sofa_find_package(Sofa.Simulation.Core REQUIRED)
sofa_find_package(Sofa.Component.ODESolver.Backward REQUIRED)
sofa_find_package(Sofa.Component.LinearSolver.Iterative REQUIRED)
sofa_find_package(Sofa.Component.LinearSolver.Direct REQUIRED)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${WRAPPER_FILES})
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Simulation.Core Sofa.Component.ODESolver.Backward Sofa.Component.LinearSolver.Iterative Sofa.Component.LinearSolver.Direct)

sofa_create_package_with_targets(
    PACKAGE_NAME ${PROJECT_NAME}
    PACKAGE_VERSION ${Sofa_VERSION}
    TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
    INCLUDE_SOURCE_DIR "src"
    INCLUDE_INSTALL_DIR "${PROJECT_NAME}"
)
